package com.ws.shop.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.ws.shop.bean.Page;
import com.ws.shop.dao.MessageDao;
import com.ws.shop.entity.Message;
import com.ws.shop.service.MessageService;

@Service(value="messageService")
public class MessageServiceImpl implements MessageService {

	@Resource(name="messageDao")
	private MessageDao messageDao;
	
	@Transactional(propagation=Propagation.NOT_SUPPORTED,readOnly=true)
	public void getMessages(final Page page,final int state) {
		messageDao.getMessages(page,state);
	}
	
	@Transactional(propagation=Propagation.NOT_SUPPORTED,readOnly=true)
	public Page findMessageListByPage(int pageno, int pagesize, String start,
			String end, String name, int aid) {
		return messageDao.findMessageListByPage(pageno, pagesize, start, end, name, aid);
	}

	@Transactional(propagation=Propagation.NOT_SUPPORTED,readOnly=true)
	public void getMessageByUid(Page page, int state, long uid) {
		messageDao.getMessageByUid(page, state, uid);
	}

	@Transactional(rollbackFor=Exception.class)
	public int saveMessage(Message message) {
		return messageDao.saveMessage(message);
	}

	@Transactional(rollbackFor=Exception.class)
	public void reply(Message message) {
		messageDao.reply(message);
	}

	@Transactional(propagation=Propagation.NOT_SUPPORTED,readOnly=true)
	public Message findMessageById(int id) {
		return messageDao.findMessageById(id);
	}

}
